<template>
  <div>
    <h1>
      历史搜索记录
      <span style="font-size: 15px">(仅显示最后50条)</span>
    </h1>
    <el-table :data="tableData" style="width: 57%">
      <el-table-column prop="name" label="匹配地址"></el-table-column>
      <el-table-column prop="res" label="反馈地址"></el-table-column>
      <el-table-column prop="date" label="匹配时间"></el-table-column>
    </el-table>
    <!-- <div class="block">
      <el-pagination
        layout="total, sizes, prev, pager, next, jumper"
        :total="tableData.length"
      >
      </el-pagination>
    </div> -->
  </div>
</template>

<script>
export default {
  data() {
    return {
      tableData: [],
    };
  },
  methods: {
    async getAddress() {
      var param = new FormData();
      param.append("token", window.sessionStorage["token"]);
      const { data: res } = await this.$http.post("findallhis", param, {
        headers: { "Content-Type": "application/json" },
      });
      for (let i = 0; i < res.data.length; i++) {
        res.data[i].date =
          res.data[i].date.substring(2, 10) +
          " " +
          res.data[i].date.substring(11, 19);
      }
      this.tableData = res.data;
    },
  },
  mounted() {
    this.getAddress();
    // 未登录路由到login
    if (window.sessionStorage["username"] == undefined) {
      this.$router.push({ path: "/login" });
      this.$message.error("请先登录！！！！");
    }
  },
};
</script>
<style scoped>
h1 {
  padding-top: 10px;
  font-size: 2rem;
  text-align: center;
  color: #3b3a3ab6;
}
span {
  font-size: 30px;
}
.el-table {
  text-align: center;
  margin: 0 auto;
  margin-top: 1%;
  padding-left: 50px;
}
</style>